package com.zhangye.test.api;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.zhangye.test.model.Admin;
import com.zhangye.test.model.EasyAr;
import com.zhangye.test.model.ProxyAr;
import com.zhangye.test.service.AdminService;
import com.zhangye.test.service.EasyArService;
import com.zhangye.test.service.ProxyArService;

@Component
public class TimerJob {
	@Autowired
	private ProxyArService proxyArService;

	@Autowired
	private EasyArService easyArService;
	@Autowired
	private AdminService adminService;

	@Scheduled(cron="0 0/5 * * * ?") // 每5分钟执行一次
	public void checkDate() throws ServletException, IOException {
		String where = " and status = 'audit'";
		List<ProxyAr> list = proxyArService.selectByWhere(where);
		for(int i = 0 ; i < list.size() ; i ++){
			ProxyAr pa = list.get(i);
			proxyArService.auditProxyAr(pa.getId(),null);
		}
		
		List<EasyAr> list1 = easyArService.selectByWhere(where);
		EasyAr ea;
		for(int i = 0 ; i < list1.size(); i ++){
			ea = list1.get(i);
			easyArService.auditEasyAr(ea.getId());
			
		}
	}
}
